﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using Telerik.Web.UI;
using KPIS.Utils;
using System.Web.UI.HtmlControls;

namespace KPIS.GERP.GHRMS.APP.App_UI.Forms
{
    public partial class RC_TempEdu : System.Web.UI.Page
    {
        private SsMng ssMng = new SsMng();
        RecruitApplicantBLL appBLL = new RecruitApplicantBLL();

        protected void Page_Load(object sender, EventArgs e)
        {         
            IncludeJava();

            if (!IsPostBack)
            {
                Session["tmp_emp_seq"] = Request.QueryString["id"];
                LoadDataGrid();               
         
            }
            
        }
        public void IncludeJava()
        {
            HtmlGenericControl script = new HtmlGenericControl();
            script.TagName = "script";
            script.Attributes.Add("type", "text/javascript");
            script.Attributes.Add("src", "../../Scripts/jsfunction.js");
            Page.Header.Controls.Add(script);
        }

        private void LoadDataGrid()
        {
            DataTable dt = appBLL.LoadEducations((int?)null, Int32.Parse(Session["tmp_emp_seq"].ToString())).Tables[0];

            RadGrid2.DataSource = dt;
            RadGrid2.DataBind();         
        }

        protected void RadGrid2_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "Delete")
                {
                    int Sequence = Convert.ToInt32((e.Item as GridDataItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex]["tmp_edu_seq"]);

                    appBLL.DeleteEducations(Sequence, ssMng.EmpSeqI);
                }
                LoadDataGrid();

                            }
            catch (Exception ex)
            {
                Web.ShowAlert(this, ex.Message);
            }

        }

    }
}
